/*
 * Controller that handles controls on the MuseumsList and MuseumDetails pages 
 */
myapp.controllers.museums = new Ext.Controller({
    index: function (options) {
    	//alert('in index controller. options: ' + options)
        myapp.views.viewport.setActiveItem(myapp.views.museumsList, options.animation);
    },
    show: function (options) {
        var id = parseInt(options.id),
        museum = myapp.stores.museums.getById(id);
        if (museum) {
        	// get page to reset scroll to top
        	myapp.views.museumDetail.scroller.scrollTo('top',0);
        	myapp.views.museumDetail.updateWithRecord(museum);
            myapp.views.viewport.setActiveItem(myapp.views.museumDetail, options.animation);
        }
    }, 
    edit: function (options) {
    },
    credits: function (options){
    	//alert('credits clicked on index controller');
    	console.error('111111111111');
    	//android.util.Log.w("MUSEUM","aaaaa"); 
    	myapp.views.viewport.setActiveItem(myapp.views.credits, options.animation);
    },
    showDetailMap: function (options){
    	if (myapp.isOnline)
    		{
		    	console.log('in showDetailMap() recordId: ' + options.id);
		        var id = parseInt(options.id),
		        museum = myapp.stores.museums.getById(id);
		        if (museum) {
		        	console.log('It\'s a museum!');
		        	myapp.views.museumDetailMap.updateWithRecord(museum);
		        	myapp.views.museumDetailMap.addMap(museum);
		        	myapp.views.viewport.setActiveItem(myapp.views.museumDetailMap, options.animation);
		        }
    		}
    	else
    		alert("No connection. Please check your data connection.");
    }
});